home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / gprof / sparc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  2.4 KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that: (1) source distributions retain this entire copyright
  7.  * notice and comment, and (2) distributions including binaries display
  8.  * the following acknowledgement:  ``This product includes software
  9.  * developed by the University of California, Berkeley and its contributors''
  10.  * in the documentation or other materials provided with the distribution
  11.  * and in all advertising materials mentioning features or use of this
  12.  * software. Neither the name of the University nor the names of its
  13.  * contributors may be used to endorse or promote products derived
  14.  * from this software without specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  */
  19. #include "gprof.h"
  20. #include "cg_arcs.h"
  21. #include "core.h"
  22. #include "hist.h"
  23. #include "symtab.h"
  24.  
  25.  
  26. void
  27. find_call (parent, p_lowpc, p_highpc)
  28.      Sym *parent;
  29.      bfd_vma p_lowpc;
  30.      bfd_vma p_highpc;
  31. {
  32.   bfd_vma dest_pc, delta;
  33.   unsigned int *instr;
  34.   Sym *child;
  35.  
  36.   delta = (bfd_vma) core_text_space - core_text_sect->vma;
  37.  
  38.   if (core_text_space == 0)
  39.     {
  40.       return;
  41.     }
  42.   if (p_lowpc < s_lowpc)
  43.     {
  44.       p_lowpc = s_lowpc;
  45.     }
  46.   if (p_highpc > s_highpc)
  47.     {
  48.       p_highpc = s_highpc;
  49.     }
  50.   DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
  51.               parent->name, p_lowpc, p_highpc));
  52.   for (instr = (unsigned int *) (p_lowpc + delta);
  53.        instr < (unsigned int *) (p_highpc + delta);
  54.        ++instr)
  55.     {
  56.       if ((*instr & CALL))
  57.     {
  58.       DBG (CALLDEBUG,
  59.            printf ("[find_call] 0x%lx: callf", (bfd_vma) instr - delta));
  60.       /*
  61.        * Regular pc relative addressing check that this is the
  62.        * address of a function.
  63.        */
  64.       dest_pc = ((bfd_vma) (instr + (*instr & ~CALL))) - delta;
  65.       if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
  66.         {
  67.           child = sym_lookup (&symtab, dest_pc);
  68.           DBG (CALLDEBUG,
  69.            printf ("\tdest_pc=0x%lx, (name=%s, addr=0x%lx)\n",
  70.                dest_pc, child->name, child->addr));
  71.           if (child->addr == dest_pc)
  72.         {
  73.           /* a hit:  */
  74.           arc_add (parent, child, 0);
  75.           continue;
  76.         }
  77.         }
  78.       /*
  79.        * Something funny going on.
  80.        */
  81.       DBG (CALLDEBUG, printf ("\tbut it's a botch\n"));
  82.     }
  83.     }
  84. }
  85.